﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SaleOnlineSystem.Admin.Controls
{
    public partial class ListNews : System.Web.UI.UserControl
    {
        public int count;
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                count = 1;
                rpt_news.DataSource = DAL.DCollector.DBCollector.Instance.CallStored("callstored", "Select * from tbl_News", true);

                rpt_news.DataBind();
            }
            catch (Exception)
            {
                Response.Redirect("/error.htm");
            }           
        }

        protected void rpt_news_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "delete")
                {
                    // Xoa
                    int id = Convert.ToInt32(e.CommandArgument.ToString());
                    DAL.DCollector.DBCollector.Instance.StoredProcedureDeleteByRows("tbl_News", "News_ID", id.ToString());
                    Response.Redirect("/Admin/Index.aspx?panel=7&sub=10");
                }
            }
            catch (Exception)
            {
                Response.Redirect("/error.htm");
            }           
        }
    }
}